/**
 * @author MyPC
 * @date 2018/6/28
 */

/**
 * 过滤管理器  - 过滤管理器管理过滤器和过滤器链。
 */
public class FilterManager {
    FilterChain filterChain;

    private Target mTarget;
    public static FilterManager instance;


    public static FilterManager getInstance() {
        if (instance == null) {
            synchronized (FilterManager.class) {
                if (instance == null) {
                    instance = new FilterManager();
                }
            }
        }
        return instance;
    }


    public void setTarget(Target target) {
        filterChain.setTarget(target);
    }

    private FilterManager() {
        filterChain = new FilterChain();

    }


    public void setFilter(Filter filter) {
        filterChain.addFilter(filter);
    }

    public void filterRequest(String request) {
        filterChain.execute(request);
    }
}